<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
  <th:block th:include="include :: header('采购计划')"/>
  <link rel="stylesheet" href="../../../../../../../../../../../../css/navigation.css">
</head>
<body class="gray-bg">
<div class="navigation visible-xs-block">
  <ol class="breadcrumb">
    <span> > </span>
    <li><a href="#" onclick="gomain()">主页</a></li>
    <li style="color: black">采购计划</li>
  </ol>
  <div class="aLine"></div>
</div>
<div class="container-div">
  <div class="row">
    <div class="col-sm-12 search-collapse">
      <form id="formId">
        <div class="select-list">
          <ul>
            <li hidden>
              <label>材料类型：</label>
              <input type="text" name="matTypes"/>
            </li>
            <li hidden>
              <label>材料分类：</label>
              <input type="text" name="matClassifications"/>
            </li>
            <li hidden>
              <label>材料数据：</label>
              <input type="text" name="matDatas"/>
            </li>
            <li hidden>
              <label>材料详情：</label>
              <input type="text" name="matDetailss"/>
            </li>
            <li hidden>
              <label>材料数量：</label>
              <input type="text" name="matNumbers"/>
            </li>
            <li hidden>
              <label>申请人：</label>
              <input type="text" name="mPeoples"/>
            </li>
            <li hidden>
              <label>状态：</label>
              <select name="mStatus">
                <option value="">所有</option>
              </select>
            </li>
            <!--                        <li class="select-time">-->
            <!--                            <label>创建时间：</label>-->
            <!--                            <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginMMtime]"/>-->
            <!--                            <span>-</span>-->
            <!--                            <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endMMtime]"/>-->
            <!--                        </li>-->
            <li hidden>
              <label>审批意见：</label>
              <input type="text" name="mOpinions"/>
            </li>
            <li hidden>
              <label>项目外键：</label>
              <input type="text" name="mId"/>
            </li>
            <!--                        查询父表建筑名 和创建时间-->
            <li>
              <label>项目名称：</label>
              <input type="text" name="pName"/>
            </li>
            <li class="select-time">
              <label style="width: 120px">项目创建时间：</label>
              <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginPTime]"/>
              <span>-</span>
              <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endPTime]"/>
            </li>
            <li>
              <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
              <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
            </li>
          </ul>
        </div>
      </form>
    </div>

    <!--            <div class="btn-group-sm" id="toolbar" role="group">-->
    <!--                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="ruoyi:requisitiones:add">-->
    <!--                    <i class="fa fa-plus"></i> 添加-->
    <!--                </a>-->
    <!--                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="ruoyi:requisitiones:edit">-->
    <!--                    <i class="fa fa-edit"></i> 修改-->
    <!--                </a>-->
    <!--                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="ruoyi:requisitiones:remove">-->
    <!--                    <i class="fa fa-remove"></i> 删除-->
    <!--                </a>-->
    <!--                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="ruoyi:requisitiones:export">-->
    <!--                    <i class="fa fa-download"></i> 导出-->
    <!--                </a>-->
    <!--            </div>-->
    <div class="col-sm-12 select-table table-bordered">
      <table id="bootstrap-table"></table>
    </div>
  </div>
</div>
<th:block th:include="include :: footer"/>
<script src="../../../../../../../../../../../../js/breadcrumb.js"></script>
<script th:inline="javascript">
  var editFlag = [[${@permission.hasPermi('ruoyi:requisitiones:edit')}]];
  var removeFlag = [[${@permission.hasPermi('ruoyi:requisitiones:remove')}]];
  var creadFlag = [[${@permission.hasPermi('ruoyi:requisitiones:add')}]];
  var prefixs = ctx + "ruoyi/purchaseplan";
  var prefix = ctx + "system/building";
  //审批状态字典
  var mStatus = [[${@dict.getType('mate_status')}]];
  var mIsover = [[${@dict.getType('purchaseplan_status')}]];
  $(function () {
    var options = {
      url: prefix + "/list",
      createUrl: prefixs + "/add/{id}",
      exportUrl: prefix + "/export",
      removeUrl: prefixs + "/remove",
      updateUrl: prefixs + "/edit/{id}",
      modalName: "采购计划列表",
      showColumns: false,
      detailView: true,
      mobileResponsive: false,
      cardView: true,
      onExpandRow: function (index, row, $building) {
        initChildTable(index, row, $building);
      },
      columns: [
        {
          field: 'pId',
          title: '项目id',
          visible: false
        },
        {
          field: 'pName',
          title: '项目名称'
        },
        {
          field: 'pFounder',
          title: '项目经理'
        },
        {
          field: 'pTime',
          title: '项目日期',
          sortable: true
        },
      ]
    };
    $.table.init(options);
  });

  function edit() {
    var url = ctx + "ruoyi/edit/" + pId;
    $.modal.openTab('详情', url);
  }

  initChildTable = function (index, row, $building) {
    var childTable = $building.html('<table style="table-layout:fixed"></table>').find('table');
    $(childTable).bootstrapTable({
      url: prefixs + "/lists",
      method: 'post',
      sidePagination: "server",
      contentType: "application/x-www-form-urlencoded",
      sortName: 'mMtime',
      sortOrder: 'desc',
      queryParams: {
        mId: row.pId
      },
      columns: [
        {
          field: 'mMid',
          title: '主键id',
          visible: false
        },
        {
          field: 'mPeoples',
          title: '申请人',
          width: 100,
          cellStyle: function (value, row, index) {
            if (row.mIsover == 1) {
              return {css: {"background-color": "lightgreen"}}
            } else {
              return {css: {"background-color": "khaki"}}
            }
          }
        },
        {
          field: 'matTypes',
          title: '材料类型',
          visible: false,
          cellStyle: function (value, row, index) {
            if (row.mIsover == 1) {
              return {css: {"background-color": "lightgreen"}}
            } else {
              return {css: {"background-color": "khaki"}}
            }
          }
        },
        {
          field: 'matClassifications',
          title: '材料分类',
          visible: false,
          cellStyle: function (value, row, index) {
            if (row.mIsover == 1) {
              return {css: {"background-color": "lightgreen"}}
            } else {
              return {css: {"background-color": "khaki"}}
            }
          }
        },
        {
          field: 'matDatas',
          title: '材料数据',
          visible: false,
          cellStyle: function (value, row, index) {
            if (row.mIsover == 1) {
              return {css: {"background-color": "lightgreen"}}
            } else {
              return {css: {"background-color": "khaki"}}
            }
          }
        },
        {
          field: 'matDetailss',
          title: '材料详情',
          width: 100,
          cellStyle: function (value, row, index) {
            if (row.mIsover == 1) {
              return {css: {"background-color": "lightgreen"}}
            } else {
              return {css: {"background-color": "khaki"}}
            }
          }
        },
        // {
        //     field: 'matNumbers',
        //     title: '材料数量',
        //     width: 100,
        //     cellStyle:function (value,row,index) {
        //         if(row.mIsover ==1){
        //             return {css:{"background-color":"lightgreen"}}
        //         }else{
        //             return {css:{"background-color":"khaki"}}
        //         }
        //     }
        // },
        {
          title: '已购数量&nbsp/&nbsp库存拿取&nbsp/&nbsp需求数量',
          width: 120,
          align: "center",
          formatter: function (value, row, index) {
            var matNumbers = "<span>" + row["mBuy"] + "</span>" + "&nbsp/&nbsp" + "<span>" + row["mLocal"] + "</span>" + "&nbsp/&nbsp" + "<span>" + row["matNumbers"] + "</span>"
            return matNumbers;
          },
          cellStyle: function (value, row, index) {
            if (row.mIsover == 1) {
              return {css: {"background-color": "lightgreen","color":"blue"}}
            } else {
              return {css: {"background-color": "khaki","color":"blue"}}
            }
          }
        },
        // {
        //     field: 'mBuy',
        //     title: '已购数量',
        //     width: 100,
        //     cellStyle:function (value,row,index) {
        //         if(row.mIsover ==1){
        //             return {css:{"background-color":"lightgreen"}}
        //         }else{
        //             return {css:{"background-color":"khaki"}}
        //         }
        //     }
        // },
        // {
        //     field: 'mLocal',
        //     title: '库存拿取',
        //     width: 100,
        //     cellStyle:function (value,row,index) {
        //         if(row.mIsover ==1){
        //             return {css:{"background-color":"lightgreen"}}
        //         }else{
        //             return {css:{"background-color":"khaki"}}
        //         }
        //     }
        // },
        {
          field: 'mUnbuy',
          title: '未购数量',
          width: 100,
          align: 'center',
          cellStyle: function (value, row, index) {
            if (row.mIsover == 1) {
              return {css: {"background-color": "lightgreen","color":"blue"}}
            } else {
              return {css: {"background-color": "khaki","color":"blue"}}
            }
          }
        },
        // {
        //     field: "mBusiness",
        //     title: '采购商家',
        //     width: 100,
        //     cellStyle:function (value,row,index) {
        //         if(row.mIsover ==1){
        //             return {css:{"background-color":"lightgreen"}}
        //         }else{
        //             return {css:{"background-color":"khaki"}}
        //         }
        //     }
        // },
        // {
        //     field: "mPrice",
        //     title: "材料单价",
        //     width: 100,
        //     cellStyle:function (value,row,index) {
        //         if(row.mIsover ==1){
        //             return {css:{"background-color":"lightgreen"}}
        //         }else{
        //             return {css:{"background-color":"khaki"}}
        //         }
        //     }
        // },
        {
          field: 'mIsover',
          title: '任务状态',
          align: "center",
          width: 100,
          formatter: function (value, row, index) {
            return $.table.selectDictLabel(mIsover, value);
          },
          cellStyle: function (value, row, index) {
            if (row.mIsover == 1) {
              return {css: {"background-color": "lightgreen"}}
            } else {
              return {css: {"background-color": "khaki"}}
            }
          }
        },
        {
          field: 'mMtime',
          title: '创建时间',
          width: 100,
          cellStyle: function (value, row, index) {
            if (row.mIsover == 1) {
              return {css: {"background-color": "lightgreen"}}
            } else {
              return {css: {"background-color": "khaki"}}
            }
          }
        },
        {
          title: '操作',
          align: 'center',
          width: 100,
          // formatter: function (value, row, index) {
          //   var actions = [];
          //   actions.push('<a class="btn btn-success btn-xs' + editFlag + '" href="javascript:void(0)" onclick="edit(\'' + row.mMid + '\')"><i class="fa fa-list-ul"></i> 采购详情</a> ');
          //   return actions.join('');
          // },
          formatter: function(value, row, index) {
              var actions = [];
              if(row.mIsover==0) {
                  actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="clicks(\'' + row.mMid + '\')"><i class="fa fa-user"></i>采购数量</a> ');
                  actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="luc(\'' + row.matDetailss + '\')"><i class="fa fa-user"></i>库存</a> ');
              }
                  return actions.join('' );
          },
          cellStyle: function (value, row, index) {
            if (row.mIsover == 1) {
              return {css: {"background-color": "lightgreen"}}
            } else {
              return {css: {"background-color": "khaki"}}
            }
          }
        }
      ]
    });
  };

  function edit(mMid) {
    var url = ctx + "ruoyi/edit/" + mMid;
    $.modal.openFull('采购详情', url);
  }

  function clicks(mMid) {
    var url = ctx + "ruoyi/purchaseplan/price/" + mMid;
    $.modal.open("添加已购材料", url);
  }

  function luc(matDetailss) {
    var url = ctx + "ruoyi/purchaseplan/locals/" + matDetailss;
    $.modal.open("库存", url, 500, 500);
  }


</script>
</body>
</html>